package executors;

import java.util.ArrayList;

import objects.Command;
import objects.Result;
import objects.SortedEventList;
import objects.Event;
import test.DummyEventGenerator;

public class AddExecutor {
	public static Result execute(Command command, SortedEventList data,
			SortedEventList completeTasks) {

		Event task = new Event();
		ArrayList<Event> list = new ArrayList<Event>();
		boolean isSuccessful = true;
            
			task.setDetails(command.getDetail());
			task.setPriority(command.getPriority());
			task.setStartDate(command.getStartDate());
			task.setEndDate(command.getEndDate());
			task.setTag(command.getTag());
             
			isSuccessful = list.add(task) && data.add(task);
			return new Result(isSuccessful, list);
		} 

	
    
	public static void main(String args[]) {
		Command command = new Command();
		Event oo=DummyEventGenerator.getDummyEvent();
		System.out.println(oo);
		command.setDetail(oo.getDetails());
		command.setStartDate(oo.getStartDate());
		SortedEventList data = new SortedEventList();
		SortedEventList completeTasks = new SortedEventList();
		Result r = execute(command, data, completeTasks);
		System.out.println("HERES ALL THE DETAILS of added Event");
		Event e = r.getData().get(0);
		System.out.println(e);
		System.out.println(data.size());
	}
}
